<?php
/*
 * Created on 14.04.2007
 * @filesource: install.extensionicons.php
 * @author: Nikolai Plath
 */

function com_install()
{

	global $database, $mosConfig_absolute_path;

	echo '<h2>Extension Icons</h2>';
	// Modify the admin icon
	//$database->setQuery( "SELECT id FROM #__components WHERE name= 'Extension Icons'" );
	//$id = $database->loadResult();

	// Add new admin menu images
//	@copy($mosConfig_absolute_path .'/components/com_joomfish/images/joomfish_icon.png', $mosConfig_absolute_path .'/includes/js/ThemeOffice/joomfish.png');
	$database->setQuery( "UPDATE #__components SET admin_menu_img = 'js/ThemeOffice/joomla_16x16.png' WHERE name= 'Extension Icons'");
	$database->query();

	echo 'Men&uuml;image erstellt <img src="images/tick.png" /><br />';

	if ( !is_writable ( "$mosConfig_absolute_path/administrator/modules/" ) )
	{
    	echo'
		<h2 style="color:red">There was a problem with your installation</h2>
       <p>The directory "' . $mosConfig_absolute_path . '/administrator/modules/" is not writeable</p>
       <p>Please:</p>
       <ul>
       <li>Uninstall Extension Icons</li>
       <li>Modify the file permissions</li>
       <li>Reinstall</li>
       </ul>
       <br/>Thanks.</p>';
	   return false;
	}
	   
	   
	// Add module
	$database->setQuery( "INSERT INTO `#__modules` (`title`, `content`, `ordering`, `position`, `checked_out`, `checked_out_time`, `published`, `module`, `numnews`, `access`, `showtitle`, `params`, `iscore`, `client_id`)"
				." VALUES ('Extension Icons', '', 0, 'header', 0, '0000-00-00 00:00:00', 1, 'mod_extensionicons', 0, 99, 0, '', 0, 1);");
	$database->query();
	$moduleID = $database->insertid();
	$database->setQuery( "INSERT INTO `#__modules_menu` (`moduleid`, `menuid`) VALUES ($moduleID, 0);");
	$database->query();

	$adminDir = dirname(__FILE__);

    @rename( $adminDir. "/modules/mod_extensionicons.xml", "$mosConfig_absolute_path/administrator/modules/mod_extensionicons.xml");
    @rename( $adminDir. "/modules/mod_extensionicons.php", "$mosConfig_absolute_path/administrator/modules/mod_extensionicons.php");

	echo 'Modul installiert <img src="images/tick.png" /><br />';

	echo 'Sch&ouml;n, dass Sie unsere Komponente benutzen <img src="images/credits.png" /><br />';
	echo 'Made 2007 by <a href="http://www.nik-it.de">NiK-IT.de</a>';
}
?>
